<template>
    <div id="authenticateUnitlist">
      <ul v-if="listData.length>0">
        <li
          v-for="(item,index) in listData"
          :key="index"
          @click="listClick(item)">
          <p style="font-weight: bold; height: 30px">
            <span style="float: left">{{ item.COMAPNY_NAME }}</span>
          </p>
          <p style="font-size: 14px; color: #848484; height: 30px">
            <span style="float: left">联系人：{{ item.LXR }}</span>
            <span style="float: right" v-if="item.SQSJ">申请时间：{{ item.SQSJ }}</span>
            <span style="float: right" >联系电话：{{item.LXDR}}</span>
          </p>
          <p style="font-size: 14px; color: #848484; height: 30px">
            <span style="float: left">单位地址：{{ item.DWDZ }}</span>
          </p>
        </li>
      </ul>
      <ul v-else>
        <div style="height: 60vh;text-align:center;padding-top: 20vh;">
          <div style="margin-bottom: 10px;">
            <img src="https://nfzjszlb.jst.zj.gov.cn/serverfile/zheliban/icon/DSF/50.png" />
          </div>
          <div>暂无数据</div>
        </div>
      </ul>
    </div>
</template>

<script>
  import { getAuthenticateUnit,FileServerProxy } from '@/utils/api'
  export default {
    name: "authenticateUnitlist",
    data(){
      return{
        listData:[]
      }
    },
    methods:{
      getData: async function () {
        if(this.$route.query.data.SCITY){
           var params = {
          accessCode: "2caf341e427cb1252dd89c8a7bbf0f75",
          cityCode:this.$route.query.data.SCITY,
          params: {
            dataguid: "69f6523e-0a8e-41bc-89f2-48573b917a77",
            searchObject: JSON.stringify([
              {field:"FWQY",value:this.$route.query.data.SCITY},
              {field:"FWLX",value:447},
            ]),
            token: window.localStorage.getItem("token"),
          },
        };
        } else{
          this.$toast.fail("请选择地市")
        }
        const res = await FileServerProxy(params);
        console.log(res)
        let data  = JSON.parse(res.data.data).Data;
        console.log(data)
        if (data){
          this.listData = data
        }
        // let params = {
        //   "tableid": "f0a36ff8c75a4eddafbecd355672c912",
        //   "currentPage": 1,
        //   "numPerPage": 10000,
        //   "complexQuery": [
        //     {
        //       "name": "DWLX",
        //       "value": "鉴定单位",
        //       "operation": "="
        //     },
        //     // {
        //     //   "name": "QYMC",
        //     //   "value": ""
        //     // }
        //   ]
        // }
        // const res = await getAuthenticateUnit(params);
        // console.log(res)
        // if (res.data.data){
        //   this.listData = res.data.data.data.resultList
        // }else{}
      },
      listClick(data){
        if (this.$route.query.data2){
          this.$router.push({
            path: '/authenticateUnitDetail',
            query: {
              data: JSON.stringify(data),
              data1:this.$route.query.data2,
              type:1,
              nowIndex:this.$route.query.nowIndex
            }
          })

        }else{
          this.$router.push({
            path: '/authenticateUnitDetail',
            query: {
              data: JSON.stringify(data),
              data1:this.$route.query.data,
              nowIndex:this.$route.query.nowIndex,
              rowGuid:this.$route.query.rowGuid,
            }
          })
        }

      }
    },
    mounted(){
      console.log(this.$route.query.data)
      this.getData()
    }
  };
</script>

<style scoped lang="scss">
  #authenticateUnitlist{
    height: 100vh;
    overflow: auto;
    padding: 10px;
    ul li {
      padding-top: 10px;
      border-bottom: 1px solid #d2d2d2;
    }

  }
</style>
